<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport"
			content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0,viewport-fit=cover" />
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title>报废出库-编辑</title>
		<link rel="stylesheet" type="text/css" href="../../css/vant.css">
		<link rel="stylesheet" type="text/css" href="../../css/base.css" />
		<link rel="stylesheet" type="text/css" href="../../css/local.css" />
		<link rel="stylesheet" type="text/css" href="../../script/layer_new/css/layui.css" />
		<script type="text/javascript" src="../../script/layer_new/layui.js"></script>
		<script type="text/javascript" src="../../script/jquery.js"></script>
		<script type="text/javascript" src="../../script/vue.min.js"></script>
		<script type="text/javascript" src="../../script/vant.min.js"></script>
		<script type="text/javascript" src="../../script/fastclick.js"></script>
		<script type="text/javascript" src="../../script/base.js"></script>
		<script type="text/javascript" src="../../script/scanTransf.js"></script>
		<style type="text/css">

		</style>
	</head>

	<body>
		<div id="app" v-cloak>
			<div class="box">
				<van-nav-bar class="head" :title="titleName" :safe-area-inset-top="true" left-arrow
					@click-left="onClickLeft">
					<span slot="right" @click="openScan" v-if="!isPDA">
						<img src="../../image/scan.png" />
					</span>
				</van-nav-bar>

				<div class="content">
					<van-collapse v-model="activeNames">
						<van-collapse-item title="表单详情" name="1" title-class="mTitle" class="custom-collapse-item">
							<template #icon>
								<div class="mIcon">
									<van-icon name='edit' size="18px" color="#51d0d0"></van-icon>
								</div>
							</template>

							<van-row class="mainContent">
								<van-col span="24">
									<van-field label="出库仓库" v-model="form.FWarehouseName" readonly
										@click="openBaseScreen('仓库')" required left-icon="wap-home-o"
										right-icon="arrow">
									</van-field>
								</van-col>
								<van-col span="24">
									<van-field label="单据日期" v-model="form.FDate" readonly @click="openDate(1)"
										left-icon="underway-o" right-icon="arrow">
									</van-field>
								</van-col>
							</van-row>

						</van-collapse-item>
					</van-collapse>

					<div class="midPanel">
						<van-button size="small" block @click="openBaseScreen('产品')">选择产品
						</van-button>
					</div>

					<div class="detail">
						<div class="detail-label">
							<div>报废明细</div>
						</div>

						<div class="detail-content">
							<div>
								<div class="button" v-if="!formDetail.length">
									<span>暂无报废数据</span>
								</div>
								<div class="rowBoxContainer">

								</div>
							</div>
						</div>
					</div>
				</div>

				<div class="bottom">
					<van-button v-if="!form.Approve" size="small" color="#51d0d0" :disabled="ifConfirm"
						:loading="ifConfirm" @click="confirmSub">保存</van-button>
					<van-button v-if="!form.Approve && form.FStockID" size="small" color="#a33d3b" :disabled="ifConfirm"
						:loading="ifConfirm" @click="ApproveSubmit">审核</van-button>
					<van-button v-if="form.Approve" size="small" color="#a33d3b" :disabled="ifConfirm"
						:loading="ifConfirm" @click="ApproveSubmit">取消审核</van-button>
				</div>
			</div>

			<van-popup v-model="showDate" position="bottom">
				<van-datetime-picker v-model="currentDate" type="date" @confirm="confirmDate" @cancel="cancelDate"
					cancel-button-text="清空" />
			</van-popup>

		</div>
	</body>
	<script src="../../script/uni.webview.1.5.4.js"></script>
	<script type="text/javascript">
		// 开启 h5 页面 与 vue主页面的 信息交互
		document.addEventListener('UniAppJSBridgeReady', function() {

		})

		var userInfo = APP.getUserInfo();
		var seqNo = 0,
			currScanRow = -1;
		var selectFid = '',
			selectFname = '';

		function scanHandler(scanData) {
			if (vm.scanDisabled) {
				layer.open({
					content: '数据提交中,请稍后再试',
					skin: 'msg',
					time: 2000
				});
				return false;
			}
			if (!scanData) {
				layer.open({
					content: '请扫描正确的条码',
					skin: 'msg',
					time: 2000
				});
				return false;
			}

			if (scanData.type == '库位') {
				vm.scanDisabled = true;
				var obj = {
					QrQZ: scanData.data.tag,
					QrCode: scanData.data.code,
					FWarehouseID: vm.form.FWarehouseID
				}
				APP.jqueryAjax('Get_QrStorage', obj, function(res) {
					vm.scanDisabled = false;
					if (res.ds[0] && res.ds[0].status == 500) {
						layer.open({
							content: res.ds[0].msg,
							skin: 'msg',
							time: 2000
						});

					} else {
						vm.form.FStorageID = res.ds[0].FStorageID;
						vm.form.FStorageCode = res.ds[0].FStorageCode;
					}

				})
			} else if (scanData.type == '箱码') {
				//仓库验证
				if (!vm.form.FWarehouseName) {
					layer.open({
						content: '请先选择仓库!',
						skin: 'msg',
						time: 2000
					});
					return false;
				}

				APP.jqueryAjax('YZ_NGCL', {
					FBoxCode: scanData.recode
				}, function(res) {
					if (res.ds[0].status == 500) {
						layer.open({
							content: res.ds[0].msg,
							skin: 'msg',
							time: 2000
						});
					} else {
						if (currScanRow == -1) {
							layer.open({
								content: '请先添加产品!',
								skin: 'msg',
								time: 2000
							});
							return false;
						} else if (currScanRow > -1) {
							vm.scanDisabled = true;
							var isExistsQrCode = vm.verifyQrCode(scanData); // 1.重复扫码验证(页面)
							var currQrCodeInfo = res.ds[0]; //箱码现存量
							if (!isExistsQrCode) {
								var codeInfo = {
									qrCode: currQrCodeInfo.FBoxCode, //箱码
									qty: currQrCodeInfo.FQty, //每箱数量
									fid: currQrCodeInfo.FStorageID, //货位ID
									fname: currQrCodeInfo.FStorageCode, //货位名称
									fbatchno: currQrCodeInfo.FBatchNo
								}
								//验证当前扫码行产品是否与箱码产品一致
								if ($('#ProductID' + currScanRow).text() != currQrCodeInfo
									.ProductID) {
									vm.scanDisabled = false;
									layer.open({
										content: '当前扫码行与箱码产品不一致!',
										skin: 'msg',
										time: 2000
									});
								} else {
									vm.insertQrCode(codeInfo, currScanRow);
								}
							} else {
								vm.scanDisabled = false;
								layer.open({
									content: '请勿重复扫码!',
									skin: 'msg',
									time: 2000
								});
							}
						}
					}
				})

			}
		}


		var vm = new Vue({
			el: '#app',
			data: {
				showLoading: false,
				ifConfirm: false,
				scanDisabled: false,
				titleName: '',
				showDate: false,
				currentDate: new Date(),
				isPDA: false,
				EBoxNum: '',
				form: {
					FStockID: 0,
					FWarehouseID: 0,
					FWarehouseName: '',
					ClientID: 0,
					ClientName: '',
					FDate: APP.getFormatDate2('yyyy-MM-dd'),
					BillNO: '',
					Approve: 0
				},
				formDetail: [],
				baseScreenObj: {}, //弹窗选择列表参数
				activeNames: ['1'],
				tabIndex: 1, // 子表页签
				isPDA: false,
				safeBottom: 0

			},
			mounted() {

			},
			created: function() {

			},
			methods: {

				// 获取单据详情
				SetServiceIP(IP) { // 从外部获取账套IP地址
					var that = this
					// console.log(IP);
					let data = JSON.parse(IP);
					APP.serverIP(data.serverIP);
					APP.IPAgreement(data.IPAgreement);
					that.form.FStockID = data.ID;
					that.titleName = data.menu.APFunName + '详情';
					that.isPDA = data.isPDA;
					that.safeBottom = data.safeBottom;
					$('.head').css({
						'padding-top': data.safeTop + 'px'
					})
					if (data.safeBottom > 0) {
						$('.bottom').css({
							'padding-bottom': data.safeBottom + 'px'
						});
					}
					setTimeout(() => {
						if (that.form.FStockID) {
							that.getPageData();
						}
					}, 300)
				},

				SetChoiceData(content) {
					let selectItem = JSON.parse(content);
					console.log(JSON.stringify(selectItem));

					if (selectItem.type == '产品') {
						vm.insertProductRow(selectItem.data);
					}

					if (selectItem.type == '仓库') {
						if (vm.form.FWarehouseName != selectItem.data.FWarehouseName) {
							vm.form.FWarehouseID = selectItem.data.FWarehouseID;
							vm.form.FWarehouseName = selectItem.data.FWarehouseName;

							vm.form.FStorageID = 0;
							vm.form.FStorageCode = '';
						}
					}
				},

				SetScanData(result) {
					let scanData = scanTransf(result);
					console.log(JSON.stringify(scanData));
					scanHandler(scanData);
				},

				rowOpenScan() {
					var that = this;
					that.openScan();
				},
				openScan() {
					this.sendMessage('openCamera', null);
				},

				//生成产品行
				insertProductRow(productInfo) {
					//验证当前增加产品行是否已存在,存在则跳过
					var isExistsRow = vm.verifyDupProductRow(productInfo);

					if (!isExistsRow) {
						var productBox =
							'<div class=\'flex-box flex-direction-c productBox\' id=\'productBox' + seqNo +
							'\'> \
                                          <div class=\'flex-box title-bg\'><div class=\'flex-main rowProduct\' id=\'rowProduct' +
							seqNo + '\'>' + productInfo.ProductName + '</div> \
                                          <div class=\'delete-img\' id=\'rowDel' + seqNo + '\'><img src=\'../../image/sc.png\' /></div> \
                                          <div class=\'hideElements\' id=\'FPMCDeID' + seqNo + '\'>' + productInfo
							.LetterOfAdviceDeID + '</div> \
                                          <div class=\'pid-value hideElements\' id=\'ProductID' + seqNo + '\'>' +
							productInfo.ProductID + '</div></div> \
                                          <div class=\'flex-box flex-direction-r productTotal\'>  \
                                              <div class=\'flex-box flex-direction-r total-left\'>  \
                                                  <div class=\'flex-main\'>合计箱数:</div>  \
                                                  <div class=\'flex-box flex-main totalBoxNum\' id=\'totalBoxNum' +
							seqNo + '\'></div>   \
                                              </div>  \
                                              <div class=\'flex-box flex-direction-r total-right\'> \
                                                  <div class=\'flex-main\'>合计数量:</div>   \
                                                  <div class=\'flex-box flex-main totalQty\' id=\'totalQty' + seqNo + '\'></div>  \
                                              </div>  \
                                          </div>  \
                                          <div class=\'flex-box flex-direction-r codeBox-title\'><div class=\'delCode-title\'>删除</div> \
                                          <div class=\'boxCode-title\'>箱码</div><div class=\'qty-title\'>数量</div><div class=\'pos-title\'>货位</div></div> \
                                          <div class=\'flex-box flex-direction-c codeBox\' id=\'codeBox' + seqNo + '\'></div> \
                                         </div>'
						$(".rowBoxContainer").prepend(productBox);
						vm.setScanRow(seqNo); //当前扫码行置第一位

						//已审核的单据隐藏删除按钮                   
						if (vm.form.Approve) {
							$("#rowDel" + seqNo).hide()
						}

						//产品行点击选中
						$("#productBox" + seqNo).click(function() {
							var productBoxNo = $(this).attr('id').replace('productBox', '');
							$("#productBox" + productBoxNo).addClass('b-p');
							vm.setScanRow(productBoxNo);
						})
						//产品行删除
						$("#rowDel" + seqNo).click(function() {
							var rowDelNo = $(this).attr('id').replace('rowDel', '');
							$("#productBox" + rowDelNo).remove();
							vm.setScanRow(-1);
						})

						seqNo += 1;
					} else {
						layer.open({
							content: '产品已存在,请勿重复添加!',
							skin: 'msg',
							time: 2000
						});
					}

					if (currScanRow > -1) {
						$('.detail-content div .button').remove();
					}
				},

				//验证产品行是否重复添加
				verifyDupProductRow(productInfo) {
					var isExistsProductRow = false;
					var matchRows = $(".rowBoxContainer").find('.rowProduct');
					//产品信息是否存在(ProductName由产品编码、名称、规格组成)
					if (matchRows.length) {
						var matchProductCodes = [];
						for (var i = 0; i < matchRows.length; i++) {
							if (matchRows.eq(i).text() == productInfo.ProductName) {
								isExistsProductRow = true;
								break;
							}
						}
					}
					return isExistsProductRow;
				},

				//箱码验证
				verifyQrCode(scanData) {
					var isExistsQrCode = false;
					var matchCodes = $(".rowBoxContainer").find('.boxCode-content');
					if (matchCodes.length) {
						for (var i = 0; i < matchCodes.length; i++) {
							if (matchCodes.eq(i).text() == scanData.recode) {
								isExistsQrCode = true;
								break;
							}
						}
					}
					return isExistsQrCode;
				},

				//插入箱码
				insertQrCode(codeInfo, existsProductSeqNo) {
					//获取当前产品行箱码最大序号
					var currProductMaxCodeIndex = 0;
					if ($("#codeBox" + existsProductSeqNo).children().length) {
						//currProductMaxCodeIndex = $("#codeBox" + existsProductSeqNo).children(':last-child').find('.codeDelBtn').attr('id').replace('codeDelBtn', '');
						currProductMaxCodeIndex = $("#codeBox" + existsProductSeqNo).children(':first-child')
							.find('.codeDelBtn').attr('id').replace('codeDelBtn' + existsProductSeqNo, '');
					}
					currProductMaxCodeIndex = parseInt(currProductMaxCodeIndex) + 1;

					//箱码行
					var codeHtml = '<div class=\'flex-box flex-direction-r boxCodeShow\'>   \
                                          <div class=\'delCode-content codeDelBtn delete-img\' id=\'codeDelBtn' +
						existsProductSeqNo + currProductMaxCodeIndex + '\'><img src=\'../../image/delete.png\'/></div>    \
                                          <div class=\'boxCode-content\' id=\'code' + existsProductSeqNo +
						currProductMaxCodeIndex + '\'>' + codeInfo.qrCode + '</div>  \
                                          <div contenteditable=\'true\' class=\'qty-content\' id=\'qty' +
						existsProductSeqNo + currProductMaxCodeIndex + '\'>' + codeInfo.qty + '</div>  \
                                          <div class=\'pos-value hideElements\' id=\'FStorageID' + existsProductSeqNo +
						currProductMaxCodeIndex + '\'>' + codeInfo.fid + '</div> \
                                          <div class=\'fbatch hideElements\' id=\'FBatchNo' + existsProductSeqNo +
						currProductMaxCodeIndex + '\'>' + codeInfo.fbatchno + '</div> \
                                          <div class=\'pos-content\' id=\'pos' + existsProductSeqNo +
						currProductMaxCodeIndex + '\'>' + codeInfo.fname + '</div> \
                                      </div>';
					$('#productBox' + existsProductSeqNo + ' .codeBox').prepend(codeHtml);
					//已审核的单据隐藏箱码删除,取消数量可编辑
					if (vm.form.Approve) {
						$("#qty" + existsProductSeqNo + currProductMaxCodeIndex).attr('contenteditable',
							false)
						$('.delCode-title').hide();
						$('.delCode-content').hide();
					}
					$("#qty" + existsProductSeqNo + currProductMaxCodeIndex).attr('contenteditable', false)

					$("#qty" + existsProductSeqNo + currProductMaxCodeIndex).blur(function() {
						vm.calcRowTotal(existsProductSeqNo);
					})
					$("#codeDelBtn" + existsProductSeqNo + currProductMaxCodeIndex).click(function() {
						var currClickBtnID = $(this).attr('id');
						vm.deleteQrCode(existsProductSeqNo, currProductMaxCodeIndex, currClickBtnID);
					})
					// $("#pos" + existsProductSeqNo + currProductMaxCodeIndex).click(function () {
					//     selectFid = $("#FStorageID" + existsProductSeqNo + currProductMaxCodeIndex).attr('id');
					//     selectFname = $(this).attr('id');
					//     console.log(JSON.stringify(selectFname));
					//     console.log(JSON.stringify(selectFid));
					//     vm.openBaseScreen('箱码库位');

					// })

					vm.calcRowTotal(existsProductSeqNo);
					vm.scanDisabled = false;
				},

				//删除箱码
				deleteQrCode(existsProductSeqNo, currProductMaxCodeIndex, currClickBtnID) {
					$('#' + currClickBtnID).parent().remove();
					//当前产品箱码数量为0时 删除当前产品节点
					if ($("#codeBox" + existsProductSeqNo).children().length == 0) {
						$("#productBox" + existsProductSeqNo).remove();
					}
					vm.calcRowTotal(existsProductSeqNo);
				},

				//设置扫描行
				setScanRow(existsProductSeqNo) {
					if (currScanRow > -1 && existsProductSeqNo == -1) {
						var productRows = $('.rowBoxContainer').children().length;
						if (productRows) {
							var firstRow = $('.rowBoxContainer').children(':first-child');
							var firstRowIndex = parseInt(firstRow.attr('id').replace('productBox', ''));
							existsProductSeqNo = firstRowIndex;
						} else {
							currScanRow = -1;
							layer.open({
								content: '已全部清空!',
								skin: 'msg',
								time: 2000
							});
						}
					} else if (currScanRow > -1 && currScanRow != existsProductSeqNo && existsProductSeqNo > -
						1) {
						$("#productBox" + currScanRow).removeClass('b-p');
						$("#productBox" + currScanRow).addClass('b-p-t');
					}
					$("#productBox" + existsProductSeqNo).removeClass('b-p-t');
					$("#productBox" + existsProductSeqNo).addClass('b-p');
					currScanRow = existsProductSeqNo; //更新当前扫码产品行
				},

				//合计扫码/箱数计算
				calcRowTotal(existsProductSeqNo) {
					var matchItems = $('#codeBox' + existsProductSeqNo).find('.qty-content');
					var totalBoxNum = 0,
						totalQty = 0;
					for (var i = 0; i < matchItems.length; i++) {
						totalBoxNum += 1;
						totalQty += Number(matchItems.eq(i).text());
					}
					$('#totalBoxNum' + existsProductSeqNo).text('' + totalBoxNum + '');
					$('#totalQty' + existsProductSeqNo).text('' + totalQty + '');
				},

				//获取历史单据详情
				getPageData() {
					var that = this;
					APP.jqueryAjax('NGCL_MXList', {
						FStockID: that.form.FStockID
					}, function(res) {
						if (res.ds.length) {
							//vm.form.ClientName = res.ds[0].ClientName;
							//vm.form.ClientID = res.ds[0].ClientID;
							vm.form.FDate = res.ds[0].FDate;
							vm.form.FWarehouseName = res.ds[0].FWarehouseName;
							vm.form.FWarehouseID = res.ds[0].FCKWarehouseID;
							//vm.form.BillNO = res.ds[0].BillNO;
							vm.form.Approve = res.ds[0].Approve;

							var curProductID = 0; //当前产品
							var codeInfo = null; //箱码信息
							for (var i = 0; i < res.ds.length; i++) {
								codeInfo = res.ds[i];
								if (curProductID != res.ds[i].ProductID) {
									curProductID = res.ds[i].ProductID
									vm.insertProductRow(codeInfo);
									vm.generatePageDe(curProductID, codeInfo);
								} else {
									//插入箱码
									vm.generatePageDe(curProductID, codeInfo);
								}
							}
						}
					})
				},

				generatePageDe(curProductID, codeInfo) {
					var matchCodes = $(".rowBoxContainer").find('.pid-value');
					var obj = null;
					if (matchCodes.length) {
						for (var i = 0; i < matchCodes.length; i++) {
							if (matchCodes.eq(i).text() == curProductID) {
								var rowNo = matchCodes.eq(i).attr('id').replace('ProductID', '');
								obj = {
									qrCode: codeInfo.FBoxCode,
									qty: codeInfo.FQty,
									fid: codeInfo.FStorageID,
									fname: codeInfo.FStorageCode,
									fbatchno: codeInfo.FBatchNo
								}
								vm.insertQrCode(obj, rowNo)
							}
						}
					}
				},

				//单据提交
				confirmSub() {
					if (!vm.form.FWarehouseName) {
						layer.open({
							content: '请先选择仓库!',
							skin: 'msg',
							time: 2000
						});
						return false;
					}

					//遍历产品行拼接数据
					var matchRows = $(".rowBoxContainer").children();
					var FPMCDeIDs = [],
						FBoxCodes = [],
						FStorageIDs = [],
						FProductIDs = [],
						FQtys = [],
						FBatchNos = []
					//产品编码是否存在
					if (matchRows.length) {
						var matchProductCodes = [];
						for (var i = 0; i < matchRows.length; i++) {
							var rowIndex = matchRows.eq(i).attr('id').replace('productBox', '');
							//var FPMCDeID = $('#FPMCDeID' + rowIndex).text();
							var ProductID = $('#ProductID' + rowIndex).text();
							var matchQrCodes = $('#codeBox' + rowIndex).children();
							for (var j = 0; j < matchQrCodes.length; j++) {
								var codeInfo = matchQrCodes.eq(j);
								var code = codeInfo.find('.boxCode-content').text();
								var qty = codeInfo.find('.qty-content').text();
								var fstorageid = codeInfo.find('.pos-value').text();
								var fbatchno = codeInfo.find('.fbatch').text();

								// if (FPMCDeID == undefined) {
								//     FPMCDeIDs.push(0);
								// } else {
								//     FPMCDeIDs.push(FPMCDeID);
								// }
								FProductIDs.push(ProductID);
								FBoxCodes.push(code);
								FQtys.push(qty);
								FStorageIDs.push(fstorageid);
								FBatchNos.push(fbatchno);
							}
						}

						var obj = {
							FStockID: vm.form.FStockID,
							FWarehouseID: vm.form.FWarehouseID,
							FProductIDs: FProductIDs.join(','),
							FBoxCodes: FBoxCodes.join(','),
							FQtys: FQtys.join(','),
							FStorageIDs: FStorageIDs.join(','),
							FBatchNos: FBatchNos.join(',')
						}

						console.log(JSON.stringify(obj));

						if (!vm.form.FStockID) {
							vm.$dialog.confirm({
								title: '提示',
								message: '是否提交此单据?',
							}).then(function() {
								if (vm.ifConfirm) return;
								vm.ifConfirm = true;

								APP.jqueryAjax('TJ_NGCL', obj, function(res) {
									vm.ifConfirm = false;
									if (res.ds[0].status == 500) {
										layer.open({
											content: res.ds[0].msg,
											skin: 'msg',
											time: 2000
										});
									} else {
										vm.$dialog.alert({
											title: '提示',
											message: '提交成功!',
										}).then(function() {
											vm.onClickLeft();
										})
									}
								})
							}).catch(function() {

							});
						} else {
							vm.$dialog.confirm({
								title: '提示',
								message: '是否提交此编辑后的单据?',
							}).then(function() {
								if (vm.ifConfirm) return;
								vm.ifConfirm = true;

								APP.jqueryAjax('TJ_NGCL_EDIT', obj, function(res) {
									vm.ifConfirm = false;
									if (res.ds[0].status == 500) {
										layer.open({
											content: res.ds[0].msg,
											skin: 'msg',
											time: 2000
										});
									} else {
										vm.$dialog.alert({
											title: '提示',
											message: '提交成功!',
										}).then(function() {
											vm.onClickLeft();
										})
									}
								})
							}).catch(function() {

							});
						}

					} else {
						layer.open({
							content: '提交产品不能为空!',
							skin: 'msg',
							time: 2000
						});
						return false;
					}

				},
				ApproveSubmit() {
					var that = this;
					let obj = {};
					obj.FStockID = that.form.FStockID;
					obj.isApprove = that.form.Approve ? 1 : 0;
					console.log(JSON.stringify(obj));
					vm.$dialog.confirm({
						title: '提示',
						message: that.form.Approve ? '是否取消审核此单据?' : '是否审核此单据?',
					}).then(function() {
						if (vm.ifConfirm) return;
						vm.ifConfirm = true;

						APP.jqueryAjax('NGCL_Approve', obj, function(res) {
							vm.ifConfirm = false;
							if (res.ds[0].status == 500) {
								layer.open({
									content: res.ds[0].msg,
									skin: 'msg',
									time: 2
								});
							} else {
								vm.$dialog.alert({
									title: '提示',
									message: res.ds[0].msg,
								}).then(function() {
									vm.onClickLeft();
								})
							}
						})
					}).catch(function() {

					});

				},
				openDate(index) {
					var that = this;
					that.currentDate = new Date();
					that.showDate = true;
				},
				confirmDate(value) {
					var that = this;
					that.form.FDate = APP.getFormatDate2('yyyy-MM-dd', value);
					that.showDate = false;
				},
				cancelDate(value) {
					var that = this;
					that.form.FDate = '';
					that.showDate = false;
				},

				openBaseScreen(str) {
					var that = this;

					if (str == '产品') {
						vm.baseScreenObj = {
							allowClear: false,
							cmd: 'Droplist_Product',
							type: str,
							ListeningName: 'WmsEditChoice',
							refresherEnabled: false,
							serverSearch: {
								isPaging: false, //是否分页
								searchKey: 'ProductName',
								showText: 'ProductName', //查询结果显示的字段
								ChoiceDataKey: 'ProductID',
							},
							param: {
								ProductName: '',
							}
						}
					}

					if (str == '仓库') {
						vm.baseScreenObj = {
							allowClear: false,
							cmd: 'Down_WarehouseCP',
							type: str,
							ListeningName: 'WmsEditChoice',
							refresherEnabled: false,
							serverSearch: {
								isPaging: false, //是否分页
								showText: 'FWarehouseName', //查询结果显示的字段
								ChoiceDataKey: 'FWarehouseID',
								ChoiceDataData: vm.form.FWarehouseID
							},
							param: {

							}
						}
					}

					this.sendMessage('baseScreen', vm.baseScreenObj);
				},

				sendMessage(action, data) {
					uni.postMessage({
						data: {
							action: action,
							data: data
						}
					})
				},

				onClickLeft() {
					uni.navigateBack();
				}
			}
		})
	</script>

</html>